//
//  CommonHelper.m
//  meets-ios
//
//  Created by wangjun on 26/5/15.
//  Copyright (c) 2015 meets. All rights reserved.
//

#import "CommonHelper.h"
#import <sys/utsname.h>

@implementation CommonHelper

+ (CGFloat)headerHeightWithController:(UIViewController *)controller {
    if (controller.navigationController) {
        CGFloat height = controller.navigationController.navigationBar.height;
        return height + STATUSBAR_HEIGHT;
    } else {
        return STATUSBAR_HEIGHT;
    }
}

+ (NSString *)deviceInfo {
    struct utsname systemInfo;
    uname(&systemInfo);
    
    NSString *deviceInfo = [NSString stringWithCString:systemInfo.machine encoding:NSASCIIStringEncoding];
    
    if ([deviceInfo isEqualToString:@"iPhone3,1"]) return @"iPhone 4";
    if ([deviceInfo isEqualToString:@"iPhone3,2"]) return @"iPhone 4";
    if ([deviceInfo isEqualToString:@"iPhone3,3"]) return @"iPhone 4";
    if ([deviceInfo isEqualToString:@"iPhone4,1"]) return @"iPhone 4S";
    if ([deviceInfo isEqualToString:@"iPhone5,1"]) return @"iPhone 5";
    if ([deviceInfo isEqualToString:@"iPhone5,2"]) return @"iPhone 5";
    if ([deviceInfo isEqualToString:@"iPhone5,3"]) return @"iPhone 5c";
    if ([deviceInfo isEqualToString:@"iPhone5,4"]) return @"iPhone 5c";
    if ([deviceInfo isEqualToString:@"iPhone6,1"]) return @"iPhone 5s";
    if ([deviceInfo isEqualToString:@"iPhone6,2"]) return @"iPhone 5s";
    if ([deviceInfo isEqualToString:@"iPhone7,1"]) return @"iPhone 6 Plus";
    if ([deviceInfo isEqualToString:@"iPhone7,2"]) return @"iPhone 6";
    if ([deviceInfo isEqualToString:@"iPhone8,1"]) return @"iPhone 6s Plus";
    if ([deviceInfo isEqualToString:@"iPhone8,2"]) return @"iPhone 6s";
    
    if ([deviceInfo isEqualToString:@"iPod1,1"])   return @"iPod Touch 1G";
    if ([deviceInfo isEqualToString:@"iPod2,1"])   return @"iPod Touch 2G";
    if ([deviceInfo isEqualToString:@"iPod3,1"])   return @"iPod Touch 3G";
    if ([deviceInfo isEqualToString:@"iPod4,1"])   return @"iPod Touch 4G";
    if ([deviceInfo isEqualToString:@"iPod5,1"])   return @"iPod Touch 5G";
    
    if ([deviceInfo isEqualToString:@"iPad1,1"])   return @"iPad 1G";
    
    if ([deviceInfo isEqualToString:@"iPad2,1"])   return @"iPad 2";
    if ([deviceInfo isEqualToString:@"iPad2,2"])   return @"iPad 2";
    if ([deviceInfo isEqualToString:@"iPad2,3"])   return @"iPad 2";
    if ([deviceInfo isEqualToString:@"iPad2,4"])   return @"iPad 2";
    if ([deviceInfo isEqualToString:@"iPad2,5"])   return @"iPad Mini 1G";
    if ([deviceInfo isEqualToString:@"iPad2,6"])   return @"iPad Mini 1G";
    if ([deviceInfo isEqualToString:@"iPad2,7"])   return @"iPad Mini 1G";
    
    if ([deviceInfo isEqualToString:@"iPad3,1"])   return @"iPad 3";
    if ([deviceInfo isEqualToString:@"iPad3,2"])   return @"iPad 3";
    if ([deviceInfo isEqualToString:@"iPad3,3"])   return @"iPad 3";
    if ([deviceInfo isEqualToString:@"iPad3,4"])   return @"iPad 4";
    if ([deviceInfo isEqualToString:@"iPad3,5"])   return @"iPad 4";
    if ([deviceInfo isEqualToString:@"iPad3,6"])   return @"iPad 4";
    
    if ([deviceInfo isEqualToString:@"iPad4,1"])   return @"iPad Air";
    if ([deviceInfo isEqualToString:@"iPad4,2"])   return @"iPad Air";
    if ([deviceInfo isEqualToString:@"iPad4,3"])   return @"iPad Air";
    if ([deviceInfo isEqualToString:@"iPad4,4"])   return @"iPad Mini 2G";
    if ([deviceInfo isEqualToString:@"iPad4,5"])   return @"iPad Mini 2G";
    if ([deviceInfo isEqualToString:@"iPad4,6"])   return @"iPad Mini 2G";
    
    if ([deviceInfo isEqualToString:@"i386"])      return @"iPhone Simulator";
    if ([deviceInfo isEqualToString:@"x86_64"])    return @"iPhone Simulator";
    return deviceInfo;
}


@end
